package com.forum.controller;

import com.forum.common.Result;
import com.forum.dto.AdminCreateRequest;
import com.forum.dto.AdminLoginRequest;
import com.forum.dto.LoginRequest;
import com.forum.dto.LoginResponse;
import com.forum.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/admin")
public class AdminController {

    @Autowired
    private UsersService adminUserService;



    @PostMapping("/create")
    public Result<String> createAdmin(@RequestBody AdminCreateRequest req) {
        return adminUserService.createAdmin(req);
    }

    @PostMapping("/delete")
    public Result<String> deleteAdmin(@RequestBody Integer adminId) {
        return adminUserService.deleteAdmin(adminId);
    }

    //    login
    @PostMapping("/login")
    public Result<String> login(@RequestBody AdminLoginRequest req) {
        return adminUserService.login(req);
    }


    @PostMapping("/register")
    public Result<String> register(@RequestBody AdminLoginRequest req) {
        return adminUserService.adminRegister(req);
    }


    // 禁用用户
    @PostMapping("/editUserStatus")
    public Result<String> editUserStatus(@RequestBody Integer userId) {
        return adminUserService.editUserStatus(userId);
    }


}
